package org.jeecg.modules.sistersophie.facade.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.sistersophie.entity.AccountInfo;
import org.jeecg.modules.sistersophie.entity.AccountTransaction;
import org.jeecg.modules.sistersophie.facade.AccountInfoFacade;
import org.jeecg.modules.sistersophie.service.IAccountInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;

@Service
public class AccountInfoFacadeService implements AccountInfoFacade {

    @Autowired
    private IAccountInfoService accountInfoService;

    public AccountInfo selectByStudentAndType(Integer studentId,Integer type){
        AccountInfo accountInfo = new AccountInfo();
        accountInfo.setIsDelete(0);
        accountInfo.setStudentId(studentId);
        accountInfo.setAccountType(type);
        QueryWrapper<AccountInfo> queryWrapper = new QueryWrapper<AccountInfo>(accountInfo);
        return accountInfoService.getOne(queryWrapper);
    }

    @Override
    public int addAccount(Integer id, BigDecimal amount, Integer version) {
        return accountInfoService.addAccount(id,amount,version);
    }

    @Override
    public int subAccount(Integer id, BigDecimal amount, Integer version) {
        return accountInfoService.subAccount(id,amount,version);
    }

    @Override
    public int freeAccount(Integer id, BigDecimal amount, Integer version) {
        return accountInfoService.freeAccount(id,amount,version);
    }

    @Override
    public int unFreeAccount(Integer id, BigDecimal amount, Integer version) {
        return accountInfoService.unFreeAccount(id,amount,version);
    }

}
